#ifndef __MEMASSIGN_C
#define __MEMASSIGN_C
#include "memassign.h"
int g_offset,l_offset,p_offset = 0;

void localVarSize(WORDPTR symbol){
   if(symbol->blockLevel == 1){
      symbol->offset = g_offset;
      g_offset += symbol->type->offset;
   }
   else{
      symbol->offset=l_offset;
      l_offset+=symbol->type->offset;
   }
}
void programVarSize(){

}
void funcVarSize(){

}

void paramVarSize(WORDPTR funct,WORDPTR list){
   p_offset = 0;
   WORDPTR nuevo;
   while(list){
      nuevo = (WORDPTR)malloc(sizeof(WORD));
      nuevo->name = (char*)strsave(list->name);
      nuevo->kind = PARAM;
      nuevo->blockLevel = list->blockLevel;
      nuevo->type = list->type;

      p_offset-=list->type->offset;
      nuevo->offset = p_offset;
      list->offset = p_offset;

      list=list->S.link;
      nuevo->S.link = funct->S.link; //mete por principio,da la vuelta
      funct->S.link = nuevo;
   }


}

#endif


